<?php $this->context->layout = 'form';?>
<style>
    #pathss{
        width: 50% !important;
        display: inline !important;
    }
</style>
<form class="form-horizontal m" id="form-admin-add">
    <?= \common\widgets\FormInput::widget(['name'=>'formradio|位置','extend'=>['name'=>'position','required'=>1,'info'=>$info,'data'=>$this->params['positionAll']]])?>
    <?= \common\widgets\FormInput::widget(['name'=>'input','extend'=>['name'=>'id','type'=>'hidden','info'=>$info]])?>
    <?= \common\widgets\FormInput::widget(['name'=>'image|图片','extend'=>['data'=>$info['img'],'link'=>'false','name'=>'imgarr1','id'=>'uploadimgbtn1','required'=>1,'script_after'=>'1','cat'=>'bmimage','water'=>'true','sm'=>3, 'tips' => '建议尺寸：宽750px*高400px，jpg，jpeg，png格式']])?>
    <input type="hidden" name="img" id="img1" value="">
    <?= \common\widgets\FormInput::widget(['name'=>'forminput|排序','extend'=>['name'=>'sort','type'=>'number','tips'=>'排序值越大越靠前','info'=>$info]])?>
    <?= \common\widgets\FormInput::widget(['name'=>'formradio|状态','extend'=>['name'=>'status','required'=>1,'info'=>$info]])?>
</form>

<?php $this->beginBlock('script'); ?>
<script>
    function submitHandler() {
        var img1 = '';
        if($("input[name='imgarr1[]']").length>0){
            $("input[name='imgarr1[]']").each(function () {
                var imgval = $(this).val();
                if(imgval){
                    if(img1 === '') {
                        img1 = imgval;
                    }
                }
            })
        }
        $("#img1").val(img1);
        if ($.validate.form()) {
            $.operate.save(oesUrl, $('#form-admin-add').serialize());
        }
    }
    $("#xuanze").click(function () {
        var path = $('input[name=path]').val();
        var url = urlcreate('<?=\yii\helpers\Url::to(['path/index'])?>','path=' + path) ;
        var options = {
            title: '链接选择',
            url: url,
            callBack: doSubmit
        };
        $.modal.openOptions(options);
    });
    function doSubmit(index, layero){
        var body = layer.getChildFrame('body', index);
        var path = body.find('input[name=newPath]').val();
        $('input[name=path]').val(path);
        layer.close(index);
    }
</script>
<?php $this->endBlock(); ?>
